package com.study.service.impl.activemq;

import com.study.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Service;

/**
 * @desc:
 * @author: panxiyi
 * @date: 2023/5/11 12:36 下午
 */

// 测试rabbitmq，临时关闭，不然冲突
//@Service
public class MessageServiceActivemqImpl implements MessageService {

    @Autowired
    private JmsMessagingTemplate jmsMessagingTemplate;

    @Override
    public void sendMessage(String id) {
        System.out.println("加入短信发送队列 -- " + id);
        jmsMessagingTemplate.convertAndSend(id);
    }

    @Override
    public String doSendMessage() {
        String id = jmsMessagingTemplate.receiveAndConvert(String.class);
        System.out.println("消费、发送短信");
        return id;
    }
}
